// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "metric.h"
#include <vespa/vespalib/util/regexp.h>

namespace metrics {

class TextWriter : public MetricVisitor {
    uint32_t _period;
    std::ostream& _out;
    std::vector<std::string> _path;
    vespalib::Regexp _regex;
    bool _verbose;

public:
    TextWriter(std::ostream& out, uint32_t period,
               const std::string& regex, bool verbose);
    ~TextWriter();

    bool visitSnapshot(const MetricSnapshot&) override;
    void doneVisitingSnapshot(const MetricSnapshot&) override;
    bool visitMetricSet(const MetricSet& set, bool) override;
    void doneVisitingMetricSet(const MetricSet&) override;
    bool visitCountMetric(const AbstractCountMetric&, bool autoGenerated) override;
    bool visitValueMetric(const AbstractValueMetric&, bool autoGenerated) override;

private:
    bool writeCommon(const Metric& m);
};

}

